# VERSION需要和本机安装的Cmake对应
cmake_minimum_required(VERSION 3.18.4)

# c++ 11
set(CMAKE_CXX_FLAGS "-std=c++11")

# 设置工程名称，最后输出的可执行文件名称
project(app)

# 使用OpenCV
# find_package(OpenCV REQUIRED)
# find_package(Protobuf REQUIRED)

set(MAIN_SRCS
    test.cpp
    ${CMAKE_SOURCE_DIR}/driver/driver_Xbox_Joystick.cpp
    ${CMAKE_SOURCE_DIR}/driver/driver_usart.cpp
    ${CMAKE_SOURCE_DIR}/utils/project.cpp
    ${CMAKE_SOURCE_DIR}/component/com_parse_data.cpp
)

set(MAIN_HDRS
    ${CMAKE_SOURCE_DIR}/driver/driver_Xbox_Joystick.h
    ${CMAKE_SOURCE_DIR}/driver/driver_usart.h
    ${CMAKE_SOURCE_DIR}/utils/project.h
    ${CMAKE_SOURCE_DIR}/component/com_parse_data.h
)

# 生成可执行文件后，为生成文件target添加库
# 添加可执行文件添加需要编译的文件
add_executable(${PROJECT_NAME} ${MAIN_SRCS} ${MAIN_HDRS})

# 确保先创建目标，再添加 include 目录
target_include_directories(${PROJECT_NAME}
    PRIVATE
    ${CMAKE_SOURCE_DIR}/driver
    ${CMAKE_SOURCE_DIR}/utils
    ${CMAKE_SOURCE_DIR}/component
)

# 定义宏 TEST
target_compile_definitions(${PROJECT_NAME}
    PRIVATE
    APP_TEST
)

target_link_libraries(${PROJECT_NAME}
    # protobuf::libprotobuf
    # ${OpenCV_LIBS}
    pthread
)
#g++ control.pb.cc main.cpp -o App -lprotobuf -lpthread -std=gnu++11
